<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <title>图书详情</title>
    <link rel="stylesheet" href="../css/detail.css">
</head>
<body>
<div class="container">
    <div class="product-image">
        <img src="${book.image}">
    </div>

    <div class="product-details">
        <h2>${book.name}</h2>
        <div class="price">价格:${book.price}元</div>
        <div class="description">
           介绍:${book.description}
        </div>
    </div>

    <div class="add-to-cart">
        <button onclick="add('${book.id}')">添加到购物车</button>
    </div>
</div>

<script>

    function add(id){
        <c:if test="${SESSION_ISLOGIN eq true}">
        window.location.href="${pageContext.request.contextPath}/user/addOne?id="+id;
        </c:if>
        <c:if test="${SESSION_ISLOGIN eq null}">
        window.alert("请先登录");
        </c:if>
    }
</script>

</body>
</html>
